<?php
if (!isset($_SESSION['login'])){
	if (!isset($_POST["username"]) && !isset($_POST["password"])){
			require_once 'vw/userside/frontPageLoginFormView.php';
	} else {
		$factory = Factories::Init();
		$db      = $factory->databaseObject("select", "user");
		if ($db->checkLogin($_POST["username"],$_POST["password"])){
			$_SESSION["login"]= $db->extractUser($_POST["username"],$_POST["password"]);
			echo "<script>$('div#page_headerlinks').load('vw/userside/topButtonsLoggedInView.php');</script>";
			require_once('vw/userside/frontPageLoggedUser.php');
		} else {
			echo "Грешна парола или потребителско име.";
			require_once 'vw/userside/frontPageLoginFormView.php';
		};
	}
} else {
	require_once('vw/userside/frontPageLoggedUser.php');
}
?>

